package com.third.customer.service.data;

import com.third.customer.model.tables.Area;
import com.third.customer.model.tables.Customer;
import com.third.customer.service.utils.ExcelColumn;
import lombok.Data;

/**
 * Created by hehuaichun on 2020/5/23.
 */
@Data
public class CustomerReport {

    public static final String[] HEADERS = {
            "customerId",
            "group",
            "name",
            "phone",
            "Currency",
            "county",
            "community",
            "address",
            "remake"
    };

    @ExcelColumn(header = "customerId", ignore = true)
    private Long id;

    @ExcelColumn(header = "group")
    private String groupName;

    @ExcelColumn(header = "name")
    private String name;

    @ExcelColumn(header = "phone")
    private String phone;

    @ExcelColumn(header = "county")
    private String county;

    @ExcelColumn(header = "community")
    private String community;

    @ExcelColumn(header = "address")
    private String address;

    @ExcelColumn(header = "remark")
    private String remark;

    public static CustomerReport convert(Customer customer, String groupName, Area area) {
        CustomerReport report = new CustomerReport();
        report.setId(customer.getId());
        report.setGroupName(groupName);
        report.setName(customer.getName());
        report.setPhone(customer.getPhone());
        report.setCounty(area.getCounty());
        report.setCommunity(area.getCommunity());
        report.setAddress(customer.getAddress());
        report.setRemark(customer.getRemark());
        return report;
    }

}
